/*  ----------------------------------------------------------------------------
 *  Arello Mobile
 *  Fast 3d Engine
 *  ----------------------------------------------------------------------------
 * Except where otherwise noted, this work is licensed under
 * http://creativecommons.org/licenses/by/3.0
 */

#ifndef __WSAIMPL_H__
#define __WSAIMPL_H__

#include <NoCopy.h>
#include <winsock2.h>
#include <Ws2tcpip.h>
//----------------------------------------------------------
// WSAImpl
//----------------------------------------------------------

namespace liba
{
namespace net
{

class WSAImpl : private Nocopy
{
	WSAEVENT event;

    static int n_created;
	static bool wsa_valid;

    static void StartWSA(void);
    static void StopWSA(void);

public:
    SOCKET socket;

    WSAImpl();
    virtual ~WSAImpl();

	bool EventSelect(long events);
	long WaitEvents();
	bool CloseEvent();

	int SetIntOption(int level, int optname, int val) const;
	int SetOption(int level, int optname, const char * val_ptr, int size) const;
	
	void Close();

	bool is_valid()const;
	bool SystemValid()const;
};

} // namespace net
} // namespace liba
using namespace liba;

#endif //__WSAIMPL_H__